const Mock = require("mockjs");
const Random = Mock.Random;
const getComponentList = require("./getComponentList");

function getStatList(len = 10) {
  const list = [];
  const componentList = getComponentList();
  for (let i = 0; i < len; i++) {
    const stat = {
      id: Random.id(),
    };
    componentList.forEach((c) => {
      const { id, type, props } = c;
      switch (type) {
        case "questionInput":
          stat[id] = Random.ctitle();
          break;
        case "questionTextarea":
          stat[id] = Random.ctitle();
          break;
        case "questionRadio":
          stat[id] = props.options[0].label;
          break;
        case "questionCheckbox":
          stat[id] = `${props.list[0].label},${props.list[1].label}`;
          break;
      }
    });
    list.push(stat);
  }
  return list;
}

module.exports = getStatList;
